<?php
namespace admin\action;

use herosphp\bean\Beans;
use herosphp\core\Controller;
use herosphp\http\HttpRequest;
use herosphp\session\Session;
use herosphp\utils\AjaxResult;

/**
 * 行情中心action
 * @author yu
 */
class QuoteAction extends CommonAction
{


    public function index(HttpRequest $request)
    {

        $this->page = $request->getParameter('page', 'intval');
        $this->pagesize = $request->getParameter('pagesize', 'intval');
        if ($this->page <= 0) $this->page = 1;
        if ($this->pagesize <= 0) $this->pagesize = 15;


        $product_name = $request->getParameter('tab');

        if ($product_name != '') {

            $conditions = array('product_name' => $product_name);
        }

        $quoteAnalysisService = Beans::get('quote.analysis.service');
        $quoteService = Beans::get('quote.quote.service');

        $result = $quoteAnalysisService->getList($this->pagesize, $this->page, $conditions);

        foreach ($result['items'] as $k => $item) {
            $result['items'][$k]['title'] = $quoteService->getQuoteTitle($item['adddate'], $item['product_name']);
        }
        $this->generatePageMenu($result['total']);

        $this->assign('items', $result['items']);
        $this->assign('tab', $product_name);

        $this->assign('breadcrumb', array('行情管理', '行情中心'));

        $this->setView('quote/index');

    }


}
